package com.bangdream.michelia.model;

import com.alibaba.fastjson.JSON;
import com.bangdream.michelia.application.AppCurrentUser;
import com.bangdream.michelia.contract.TeacherContract;
import com.bangdream.michelia.tool.retrofithttp.RetroFactory;
import com.bangdream.michelia.utils.L;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * @date on 2018/8/6 22:39
 * @email 909732184@qq.com
 * 讲师服务
 */
public class ITeacherModelImpl implements TeacherContract.ITeacherModel{
    @Override
    public Observable getTeacherList(Map<String, String> paramsMap) {
        if(paramsMap!=null) {
            paramsMap.put("delFlag","0");
        }
        String jsonString = JSON.toJSONString(paramsMap);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"),jsonString);
        return RetroFactory.getInstance().getTeacherList(AppCurrentUser.getInstance().getToken(),
                requestBody);
    }

    @Override
    public Observable getTeacherDetails(String id) {
        L.d("讲师id="+id);
        return RetroFactory.getInstance().getTeacherDetails(id,
                AppCurrentUser.getInstance().getToken());
    }
}
